package com.example.hospital.mapper;


import com.example.hospital.pojo.SystemLog;
import org.apache.ibatis.annotations.*;

import java.util.List;
/*系统日志mapper接口*/
@Mapper
public interface SystemLogMapper {

    @Select("SELECT * FROM system_log WHERE user_id = #{userId}")
    List<SystemLog> findByUserId(Integer userId);

    @Select("SELECT * FROM system_log")
    List<SystemLog> findAll();

    @Insert("INSERT INTO system_log(user_id, action, timestamp, ip_address) " +
            "VALUES(#{userId}, #{action}, NOW(), #{ipAddress})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertLog(SystemLog log);

    @Select("SELECT * FROM system_log WHERE id = #{id}")
    SystemLog findById(Integer id);
}
